<template>
  <div>
    <div v-if="loading" id="loading" class="loading">
    </div>
    <nuxt />
  </div>
</template>
<script>

import tool from '~/util/tool'
export default {
  data(){
    return {
      loading:true
    }
  },
  mounted(){
    this.setCookie('shiro_sid',tool.getUrlParam('shiro_sid'))
    this.setCookie('token',tool.getUrlParam('token'))
    this.setFrontSize()
    setTimeout(() => {
      this.loading=false
    },500) 
  },
  methods:{
    setCookie(name,value)
    {
      let Days = 30
      let exp = new Date()
      exp.setTime(exp.getTime() + Days*24*60*60*1000)
      document.cookie = name + '='+ escape (value) + ';expires=' + exp.toGMTString()
    },
    setFrontSize() {
      let doc=document
      let win=window
      let docEl = document.documentElement,
        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
        recalc = function () {
          let clientWidth = docEl.clientWidth
          if (!clientWidth) return
          // docEl.style.fontSize = 50 * (clientWidth / 1200) + 'px'
          docEl.style.fontSize =  '40px'
        }

      if (!doc.addEventListener) return
      win.addEventListener(resizeEvt, recalc, false)
      doc.addEventListener('DOMContentLoaded', recalc, false)
      // let docEl = document.documentElement
      // let clientWidth = docEl.clientWidth
      // if (!clientWidth) return
      // docEl.style.fontSize = 50 * (clientWidth / 1700) + 'px'
    }
  }
}



</script>
<style lang="less" scoped>
.loading{
  display:flex;
  justify-content: center;
  align-items: center;
  position:absolute;
  width:100%;
  height:100%;
  background:#fff;
  z-index:9999999;
}
 </style>
